package oop.core.entity;

import java.util.*;

import oop.core.ai.AI;
import oop.core.ai.CivilianAI;
import oop.core.item.*;
import oop.core.map.Location;
import oop.core.map.MovementType;

/**
 * An NPC that has a list of items to sell and understands buying and selling items.
 */
public class MerchantNPC extends NPC {
	private List<SellableItem> itemsToSell;
	
	public MerchantNPC(List<SellableItem> itemsToSell, AI AI, String[] dialogue, boolean isHostile, int viewRange, String image, String name, int direction, Location loc, boolean isVisible, Equipment equipment, Inventory inventory, List<MovementType> movementType, DerivedStats derivedStats, int givenEXP){
		// pass everything up to NPC, but set AI to default to CivilianAI (AI's have their own reference)
		super(AI, dialogue, isHostile, viewRange, image, name, direction, loc, isVisible, equipment, inventory, movementType, derivedStats, givenEXP);
		this.itemsToSell = itemsToSell;
		this.favoribility = 1;
	}
	
	public void sellItem(SellableItem i){
		if(i==null){
			return;
		}
		this.itemsToSell.add(i);
	}
	
	public SellableItem buyItem(int i){
		SellableItem ret = null;
		if(itemsToSell.size()>i && i>=0){
			ret=itemsToSell.get(i);
		}
		return ret;
	}

	public List<SellableItem> getItemsToSell() {
		return itemsToSell;
	}

	public void setItemsToSell(List<SellableItem> itemsToSell) {
		this.itemsToSell = itemsToSell;
	}

	@Override
	public String toString() {
		return "MerchantNPC [itemsToSell=" + itemsToSell + "]";
	}
	
	@Override
	public String talk()
	{
		return null;
	}
	
}
